package com.farm.bpm.form.impl;

import java.util.List;

import com.farm.bpm.form.Field;
import com.farm.bpm.form.FormParseInter;

public class DateFormParse implements FormParseInter {
	@Override
	public void saveHandle(String fieldType, List<String> parameter,
			String name, Field field) {
		if (!"date".equals(fieldType)) {
			return ;
		}
	}
	@Override
	public Field parse(String fieldType, List<String> parameter, String name,
			Field field) {
		if (!"date".equals(fieldType)) {
			return null;
		}
		StringBuffer sb = new StringBuffer();
		sb.append("<input id='" + field.getId() + "'");
		sb.append(" value='"
				+ (field.getValue() == null ? "" : field.getValue()) + "'");
		sb.append(" name='" + field.getName() + "'");
		sb.append(" type='text' class='easyui-datebox'");
		if (field.isRequired()) {
			sb.append(" required='required' ");
		}
		sb.append(" style='width: " + field.getFormWidth() + "px;'");
		sb.append(" ></input> ");
		field.setFielsHtmlEdit(sb.toString());
		return null;
	}

	@Override
	public String getfieldTypeDescribes() {
		return "activiti基本类型:日期选择";
	}

	@Override
	public String getfieldTypeFormat() {
		return "name='名称' type='date'";
	}

}
